package com.dongdongshop.service;

import com.dongdongshop.mapper.TbSellerMapper;
import com.dongdongshop.pojo.TbSeller;
import com.dongdongshop.pojo.TbSellerExample;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@DubboService
public class SellerLoginServiceImpl implements SellerLoginService {

    @Autowired
    private TbSellerMapper tbSellerMapper;

    @Override
    public boolean insert(TbSeller tbSeller) {
        int i = tbSellerMapper.insert(tbSeller);
        return i>0;
    }

    @Override
    public TbSeller selectBy(String name) {
        TbSellerExample tse = new TbSellerExample();
        TbSellerExample.Criteria criteria = tse.createCriteria();
        criteria.andSellerIdEqualTo(name);
        List<TbSeller> tbSellers = tbSellerMapper.selectByExample(tse);
        TbSeller seller = tbSellers.size() > 0 ? tbSellers.get(0) : null;
        return seller;
    }
}
